<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="usuario" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{usuarioHome.managed ? 'Edit' : 'Add'} Usuario</f:facet>





            <s:decorate id="loginField" template="layout/edit.xhtml">
                <ui:define name="label">Login</ui:define>
                <h:inputTextarea id="login"
                               cols="80"
                               rows="3"
                              value="#{usuarioHome.instance.login}"/>
            </s:decorate>



            <s:decorate id="tipoField" template="layout/edit.xhtml">
                <ui:define name="label">Tipo</ui:define>
                <h:inputText id="tipo"
                       required="true"
                          value="#{usuarioHome.instance.tipo}">
                    <a:support event="onblur" reRender="tipoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{usuarioHome.persist}"
                       disabled="#{!usuarioHome.wired}"
                       rendered="#{!usuarioHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{usuarioHome.update}"
                       rendered="#{usuarioHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{usuarioHome.remove}"
                      immediate="true"
                       rendered="#{usuarioHome.managed}"/>

            <s:button id="done"
                   value="Done"
             propagation="end"
                    view="/Usuario.xhtml"
                rendered="#{usuarioHome.managed}"/>

            <s:button id="cancel"
                   value="Cancel"
             propagation="end"
                    view="/#{empty usuarioFrom ? 'UsuarioList' : usuarioFrom}.xhtml"
                rendered="#{!usuarioHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Avisos">
        <h:form styleClass="association" id="avisosChildren">

            <h:outputText value="There are no avisos associated with this usuario."
                       rendered="#{empty usuarioHome.avisos}"/>

            <rich:dataTable value="#{usuarioHome.avisos}"
                           var="_aviso"
                      rendered="#{not empty usuarioHome.avisos}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="avisosTable">
                <rich:column sortBy="#{_aviso.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_aviso.id}"/>
                </rich:column>
                <rich:column sortBy="#{_aviso.dataCriacao}">
                    <f:facet name="header">Data criacao</f:facet>
                    <h:outputText value="#{_aviso.dataCriacao}"/>
                </rich:column>
                <rich:column sortBy="#{_aviso.dataExpiracao}">
                    <f:facet name="header">Data expiracao</f:facet>
                    <h:outputText value="#{_aviso.dataExpiracao}"/>
                </rich:column>
                <rich:column sortBy="#{_aviso.texto}">
                    <f:facet name="header">Texto</f:facet>
                    <h:outputText value="#{_aviso.texto}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{usuarioHome.managed}" id="avisos">
        <div class="actionButtons">
            <s:button id="addaviso"
                   value="Add aviso"
                    view="/AvisoEdit.xhtml"
             propagation="none">
                 <f:param name="usuarioId"
                         value="#{usuarioHome.instance.id}"/>
                 <f:param name="avisoFrom" value="Usuario"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Incidentes">
        <h:form styleClass="association" id="incidentesChildren">

            <h:outputText value="There are no incidentes associated with this usuario."
                       rendered="#{empty usuarioHome.incidentes}"/>

            <rich:dataTable value="#{usuarioHome.incidentes}"
                           var="_incidente"
                      rendered="#{not empty usuarioHome.incidentes}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="incidentesTable">
                <rich:column sortBy="#{_incidente.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_incidente.id}"/>
                </rich:column>
                <rich:column sortBy="#{_incidente.data}">
                    <f:facet name="header">Data</f:facet>
                    <h:outputText value="#{_incidente.data}"/>
                </rich:column>
                <rich:column sortBy="#{_incidente.descricao}">
                    <f:facet name="header">Descricao</f:facet>
                    <h:outputText value="#{_incidente.descricao}"/>
                </rich:column>
                <rich:column sortBy="#{_incidente.prioridade}">
                    <f:facet name="header">Prioridade</f:facet>
                    <h:outputText value="#{_incidente.prioridade}"/>
                </rich:column>
                <rich:column sortBy="#{_incidente.status}">
                    <f:facet name="header">Status</f:facet>
                    <h:outputText value="#{_incidente.status}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{usuarioHome.managed}" id="incidentes">
        <div class="actionButtons">
            <s:button id="addincidente"
                   value="Add incidente"
                    view="/IncidenteEdit.xhtml"
             propagation="none">
                 <f:param name="usuarioId"
                         value="#{usuarioHome.instance.id}"/>
                 <f:param name="incidenteFrom" value="Usuario"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Respostas">
        <h:form styleClass="association" id="respostasChildren">

            <h:outputText value="There are no respostas associated with this usuario."
                       rendered="#{empty usuarioHome.respostas}"/>

            <rich:dataTable value="#{usuarioHome.respostas}"
                           var="_resposta"
                      rendered="#{not empty usuarioHome.respostas}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="respostasTable">
                <rich:column sortBy="#{_resposta.id}">
                    <f:facet name="header">Id</f:facet>
                    <h:outputText value="#{_resposta.id}"/>
                </rich:column>
                <rich:column sortBy="#{_resposta.data}">
                    <f:facet name="header">Data</f:facet>
                    <h:outputText value="#{_resposta.data}"/>
                </rich:column>
                <rich:column sortBy="#{_resposta.texto}">
                    <f:facet name="header">Texto</f:facet>
                    <h:outputText value="#{_resposta.texto}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{usuarioHome.managed}" id="respostas">
        <div class="actionButtons">
            <s:button id="addresposta"
                   value="Add resposta"
                    view="/RespostaEdit.xhtml"
             propagation="none">
                 <f:param name="usuarioId"
                         value="#{usuarioHome.instance.id}"/>
                 <f:param name="respostaFrom" value="Usuario"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
